package com.yc.myspringboot.init;

import javax.annotation.PostConstruct;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;

import com.yc.myspringboot.mapper.DemoMapper;

@Configuration
public class DbInit {
	
	private final Logger log = LoggerFactory.getLogger(DbInit.class);
	
	@Autowired
	private DemoMapper demoMapper;
	
	@Value("${spring.datasource.url}")
	private String dbSourceUrl;
	
	@PostConstruct
	public void showDbInfo() {
//		log.info("当前连接数据库：{}", dbSourceUrl);
	}
	
	@PostConstruct
	public void initTable() {
		//初始化测试demo表
		//判断表是否存在
//		if (demoMapper.existTable() == 0) {
//			log.info("初始化测试表");
//			demoMapper.createNewTable();
//		}
//		
	}
}
